package dictcn.com.model;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;


public class AccessSinaUserInfo {
	
	private static final String PREFERENCES_NAME_SINA = "sinaUserInfo";

	public static void keepUserInfo(Context context, String name) {	
		SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME_SINA, Context.MODE_PRIVATE);
		Editor editor = pref.edit();
		editor.putString("screen_name", name);
		editor.putBoolean("bind", false);
		editor.putBoolean("sharebind", false);
		editor.commit();
	}
	
	public static void keepUserInfoBind(Context context, Boolean isBind) {	
		SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME_SINA, Context.MODE_PRIVATE);
		Editor editor = pref.edit();
		editor.putBoolean("bind", isBind);
		editor.commit();
	}
	
	public static void keepUserInfoShareBind(Context context, Boolean isBind) {	
		SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME_SINA, Context.MODE_PRIVATE);
		Editor editor = pref.edit();
		editor.putBoolean("sharebind", isBind);
		editor.commit();
	}
	
	public static void clearUserInfo(Context context){
	    SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME_SINA, Context.MODE_PRIVATE);
	    Editor editor = pref.edit();
	    editor.clear();
	    editor.commit();
	}

	public static String readUserInfo(Context context){
		SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME_SINA, Context.MODE_PRIVATE);
		return pref.getString("screen_name", "-1");
	}
	
	public static boolean readUserInfoBind(Context context){
		SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME_SINA, Context.MODE_PRIVATE);
		return pref.getBoolean("bind", false);
	}
	
	public static boolean readUserInfoShareBind(Context context){
		SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME_SINA, Context.MODE_PRIVATE);
		return pref.getBoolean("sharebind", false);
	}
}
